import request from '#/utils/requestAbort.js';
import type {
  IQueryPagePublishInfoParamsType,
  IPublishInfoParamsType,
  IQueryFQAParamsType,
  IPublishFQADataType,
} from './type';

// 查询操作日志列表
export async function postQueryOperateLog(params?: { current: number; size: number }) {
  return request('/configuration/helpCenter/queryOperateLog', {
    method: 'POST',
    data: params,
  });
}

// 查询三级tab菜单列表
export async function postQueryTabMenuList(params?: { haveInfo: boolean }) {
  return request('/configuration/helpCenter/queryTabMenuList', {
    method: 'POST',
    data: params,
  });
}

// 查询发布资料列表
export async function postQueryPagePublishInfo(params?: IQueryPagePublishInfoParamsType) {
  return request('/configuration/helpCenter/queryPagePublishInfo', {
    method: 'POST',
    data: params,
  });
}

//发布资料（上传/重新上传）
export async function postPublishInfo(params?: IPublishInfoParamsType) {
  return request('/configuration/helpCenter/publishInfo', {
    method: 'POST',
    data: params,
  });
}

//查询资料是否已存在
export async function postQueryExistFile(params?: IPublishInfoParamsType) {
  return request('/configuration/helpCenter/queryExistFile', {
    method: 'POST',
    data: params,
  });
}

//删除发布资料
export async function getRemovePublishInfo(params?: { id?: number }) {
  return request(`/configuration/helpCenter/removePublishInfo/${params?.id}`, {
    method: 'GET',
  });
}

// 上传文件
export async function upLoadFiles(params: any) {
  return request(`/annex/annex/upLoadFiles`, {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
}

//根据文件ID删除文件
export async function deleteFiles(params: { fileId?: string }) {
  return request(`/annex/annex/delete/${params?.fileId}`, {
    method: 'GET',
  });
}

//查询常见问题
export async function postQueryFQA(params?: IQueryFQAParamsType) {
  return request('/configuration/helpCenter/queryFQA', {
    method: 'POST',
    data: params,
  });
}

// 发布常见问题
export async function postPublishFQA(params?: IPublishFQADataType) {
  return request('/configuration/helpCenter/publishFQA', {
    method: 'POST',
    data: params,
  });
}

//编辑常见问题
export async function postUpdateFQA(params?: IPublishFQADataType) {
  return request('/configuration/helpCenter/updateFQA', {
    method: 'POST',
    data: params,
  });
}

// 删除常见问题
export async function postRemoveFQA(params?: IPublishFQADataType) {
  return request(`/configuration/helpCenter/removeFQA/${params?.id}`, {
    method: 'GET',
  });
}

//批量导入常见问题
export async function batchPublishFQA(params: any) {
  return request('/configuration/helpCenter/batchPublishFQA', {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
}

// 查询模板ID
export async function getTemplate(params?: any) {
  return request('/configuration/helpCenter/queryFileTemplate/help-center', {
    method: 'GET',
    params,
  });
}
